import 'package:casdon/modules/me/data/api/user_info_api.dart';

class UserInfoModel {
  final String userId;
  final String userName;
  final String? nickName;
  final String? email;
  final String? phone;
  final String sex;
  final String? birthday;
  final String? userAvatars;

  UserInfoModel({
    required this.userId,
    required this.userName,
    required this.nickName,
    required this.email,
    required this.phone,
    required this.sex,
    required this.birthday,
    required this.userAvatars,
  });

  factory UserInfoModel.initial() => UserInfoModel(
    userId: "",
    userName: "",
    nickName: "",
    email: "",
    phone: "",
    sex: "1",
    birthday: "",
    userAvatars: "",
  );

  // 静态方法转换
  static UserInfoModel fromApi(ResponseUserInfoApi response) {
    return UserInfoModel(
      userId: response.userId,
      userName: response.userName,
      nickName: response.nickName,
      email: response.email,
      phone: response.phone,
      sex: response.sex ?? "1",
      birthday: response.birthday,
      userAvatars: response.userAvatars,
    );
  }

  UserInfoModel copyWith({
    String? userId,
    String? userName,
    String? nickName,
    String? email,
    String? phone,
    String? sex,
    String? birthday,
    String? userAvatars,
  }) {
    return UserInfoModel(
      userId: userId ?? this.userId,
      userName: userName ?? this.userName,
      nickName: nickName ?? this.nickName,
      email: email ?? this.email,
      phone: phone ?? this.phone,
      sex: sex ?? this.sex,
      birthday: birthday ?? this.birthday,
      userAvatars: userAvatars ?? this.userAvatars,
    );
  }
}
